package com.zhny.aiot.leakage.valve.plugin;

import com.zhny.aiot.leakage.valve.plugin.model.LeakageDevice;
import com.zhny.aiot.leakage.valve.plugin.model.LeakageValveStoreEntry;
import com.zhny.aiot.plugin.ICenterFacilities;
import com.zhny.aiot.plugin.IDevice;
import com.zhny.aiot.plugin.model.CommandEntry;
import com.zhny.aiot.plugin.model.DeviceEntity;
import com.zhny.aiot.plugin.model.FactoryType;
import com.zhny.aiot.plugin.model.StoreEntity;
import com.zhny.aiot.plugin.zhnygateway.GatewayServer;
import com.zhny.aiot.plugin.zhnygateway.device.ZhnyDeviceFactory;
import org.pf4j.Extension;
import org.pf4j.Plugin;
import org.pf4j.PluginWrapper;

import java.util.List;

public class LeakageValvePlugin extends Plugin {
    public LeakageValvePlugin(PluginWrapper wrapper) {
        super(wrapper);
    }
    @Extension
    public static class LeakageValveFactory extends ZhnyDeviceFactory<LeakageValveStoreEntry> {

        @Override
        public List<CommandEntry> supportCommandClasses() {
            List<CommandEntry> commands = super.supportCommandClasses ();
            commands.add(CommandEntry.valueOf("openValve1", "阀门1打开","无参数",null));
            commands.add(CommandEntry.valueOf("closeValve1", "阀门1关闭","无参数", null));
            commands.add(CommandEntry.valueOf("openValve2", "阀门2打开","无参数", null));
            commands.add(CommandEntry.valueOf("closeValve2", "阀门2关闭","无参数", null));
            commands.add(CommandEntry.valueOf("openValve3", "阀门3打开","无参数" ,null));
            commands.add(CommandEntry.valueOf("closeValve3", "阀门3关闭","无参数" ,null));
            commands.add(CommandEntry.valueOf("openValve4", "阀门4打开", "无参数",null));
            commands.add(CommandEntry.valueOf("closeValve4", "阀门4关闭", "无参数",null));
            commands.add(CommandEntry.valueOf("queryStatus", "查询阀门状态", "无参数",null));
            commands.add(CommandEntry.valueOf("queryVoltage", "查询阀门电压", "无参数",null));
            return commands;
        }

        public IDevice createDevice(ICenterFacilities iCenterFacilities, DeviceEntity entity) {
            return new LeakageDevice(GatewayServer.getInstance ().getEngine () ,this,iCenterFacilities,entity);
        }

        public Class<? extends StoreEntity> storeClass() {
            return LeakageValveStoreEntry.class;
        }

        public String getId() {
            return "zhny-leakage-valve-plugin";
        }

        public String getName() {
            return "智慧水利阀门插件";
        }

        public FactoryType getType() {
            return FactoryType.ValveController;
        }


    }
}
